package cn.iocoder.yudao.module.handguard.controller.app.userbasetable1;

import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;

import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;

import cn.iocoder.yudao.module.handguard.controller.app.userbasetable1.vo.*;
import cn.iocoder.yudao.module.handguard.dal.dataobject.userbasetable1.UserBaseTable1DO;
import cn.iocoder.yudao.module.handguard.convert.userbasetable1.UserBaseTable1Convert;
import cn.iocoder.yudao.module.handguard.service.userbasetable1.UserBaseTable1Service;

@Tag(name = "小程序 - 按揭房信贷")
@RestController
@RequestMapping("/hutai/user-base-table1")
@Validated
public class UserBaseTable1Controller {

    @Resource
    private UserBaseTable1Service userBaseTable1Service;

    @PostMapping("/create")
    @Operation(summary = "创建按揭房信贷")
    public CommonResult<Long> createUserBaseTable1(@Valid @RequestBody UserBaseTable1CreateReqVO createReqVO) {
        return success(userBaseTable1Service.createUserBaseTable1(createReqVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新按揭房信贷")
    public CommonResult<Boolean> updateUserBaseTable1(@Valid @RequestBody UserBaseTable1UpdateReqVO updateReqVO) {
        userBaseTable1Service.updateUserBaseTable1(updateReqVO);
        return success(true);
    }

//    @DeleteMapping("/delete")
//    @Operation(summary = "删除按揭房信贷")
//    @Parameter(name = "id", description = "编号", required = true)
//    @PreAuthorize("@ss.hasPermission('hutai:user-base-table1:delete')")
//    public CommonResult<Boolean> deleteUserBaseTable1(@RequestParam("id") Long id) {
//        userBaseTable1Service.deleteUserBaseTable1(id);
//        return success(true);
//    }

    @GetMapping("/get")
    @Operation(summary = "获得按揭房信贷")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<UserBaseTable1RespVO> getUserBaseTable1(@RequestParam("id") Long id) {
        UserBaseTable1DO userBaseTable1 = userBaseTable1Service.getUserBaseTable1(id);
        return success(UserBaseTable1Convert.INSTANCE.convert(userBaseTable1));
    }

    @GetMapping("/list")
    @Operation(summary = "获得按揭房信贷列表")
    public CommonResult<List<UserBaseTable1RespVO>> getUserBaseTable1List(Long id) {
        List<UserBaseTable1DO> list = userBaseTable1Service.getUserBaseTable1List(id);
        return success(UserBaseTable1Convert.INSTANCE.convertList(list));
    }

//    @GetMapping("/page")
//    @Operation(summary = "获得按揭房信贷分页")
//    @PreAuthorize("@ss.hasPermission('hutai:user-base-table1:query')")
//    public CommonResult<PageResult<UserBaseTable1RespVO>> getUserBaseTable1Page(@Valid UserBaseTable1PageReqVO pageVO) {
//        PageResult<UserBaseTable1DO> pageResult = userBaseTable1Service.getUserBaseTable1Page(pageVO);
//        return success(UserBaseTable1Convert.INSTANCE.convertPage(pageResult));
//    }
//
//    @GetMapping("/export-excel")
//    @Operation(summary = "导出按揭房信贷 Excel")
//    @PreAuthorize("@ss.hasPermission('hutai:user-base-table1:export')")
//    @OperateLog(type = EXPORT)
//    public void exportUserBaseTable1Excel(@Valid UserBaseTable1ExportReqVO exportReqVO,
//              HttpServletResponse response) throws IOException {
//        List<UserBaseTable1DO> list = userBaseTable1Service.getUserBaseTable1List(exportReqVO);
//        // 导出 Excel
//        List<UserBaseTable1ExcelVO> datas = UserBaseTable1Convert.INSTANCE.convertList02(list);
//        ExcelUtils.write(response, "按揭房信贷.xls", "数据", UserBaseTable1ExcelVO.class, datas);
//    }

}
